<template>
  <div>
    <h1 class="title">欢迎使用HOTEL订房系统</h1>
    <div class="container">
      <div class="serviceBoxBar">
        <div class="serviceBox">
          <router-link class="icon" style="--i:#fd6494" to="/register">注册</router-link>
          <div class="content"></div>
        </div>
        <div class="serviceBox">
          <router-link class="icon" style="--i:#43f390" to="/login">{{ !isLogin?"登录":"切换用户"  }}</router-link>
          <div class="content"></div>
        </div>
        <div class="serviceBox">
          <router-link class="icon" style="--i:#ffb508" to="/goodsList">住酒店</router-link>
          <div class="content"></div>
        </div>
        <div class="serviceBox" v-if="isLogin">
          <router-link class="icon" style="--i:#37ba82" to="/orders">{{userName}}</router-link>
          <div class="content"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "NavBar",
  computed:{
    isLogin(){
      return window.localStorage.getItem('USERINFO')==undefined ? false : true;
    },
    userName(){
      return JSON.parse(window.localStorage.getItem('USERINFO')).userName;
    }
  }
}
</script>

<style scoped lang="less">
.title{
  //position: absolute;
  //top: 170px;
  //left: 38%;
  margin: 50px auto;
  text-align: center;
  color: #FFFFFF;
}

.container{
  position: relative;
  width: 1200px;

  .serviceBoxBar{
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
  }

  a{
    text-decoration: none;
    color: black;
  }

  .serviceBox{
    position: relative;
    width: 350px;
    height: 280px;
    background: #51446e;
    border-radius: 20px;
    overflow: hidden;

    .icon{
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: var(--i);
      transition: 0.5s;
      display: flex;
      justify-content: center;
      align-items: center;
      border-radius: 20px;

    }

    &:hover .icon{
      top: 30px;
      left: calc(50% - 40px);
      width: 80px;
      height: 80px;
      border-radius: 50%;
    }
  }
}
@media(max-width: 1000px){
  .container{
    width: 600px;
    height: 80%;

    .serviceBoxBar{
      flex-direction: column;

      .serviceBox{
        width: 80%;
        height: 50px;
        border-radius: 5px;

        .icon{
          border-radius: 5px;
        }

        &:hover .icon{
          top: 5px;
          left: 5px;
          width: 98%;
          height: 80%;
        }
      }
    }
  }
}

@media(max-width: 400px){
  .container{
    width: 400px;
    height: 80%;

    .serviceBoxBar{
      flex-direction: column;

      .serviceBox{
        width: 80%;
        height: 50px;
        border-radius: 5px;

        .icon{
          border-radius: 5px;
        }
        &:hover .icon{
          top: 5px;
          left: 5px;
          width: 98%;
          height: 80%;
        }
      }
    }
  }
}
</style>